# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

# This is a compatability version for IPython 5.x that supports Python2
_realname=prompt_toolkit
pkgbase=mingw-w64-python2-${_realname}1
pkgname="${MINGW_PACKAGE_PREFIX}-python2-${_realname}"1
pkgver=1.0.15
pkgrel=2
pkgdesc="Library for building powerful interactive command lines in Python (mingw-w64)"
url="https://github.com/jonathanslenders/python-prompt-toolkit"
arch=('any')
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python2-pygments"
         "${MINGW_PACKAGE_PREFIX}-python2-six"
         "${MINGW_PACKAGE_PREFIX}-python2-wcwidth")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python2-pytest")
source=(python-prompt-toolkit-${pkgver}.tar.gz::https://github.com/jonathanslenders/python-prompt-toolkit/archive/${pkgver}.tar.gz)
sha256sums=('e2f720a1e8149a2b56b776d68c8fb28c8211546d266301178fb982e69d0c9bed')

prepare() {
  cd "${srcdir}"
  rm -rf python2-build-${CARCH} | true
  cp -r "python-prompt-toolkit-${pkgver}" "python2-build-${CARCH}"
}

build() {
  msg "Python 2 build for ${CARCH}"  
  cd "${srcdir}/python2-build-${CARCH}"
  mv -f prompt_toolkit prompt_toolkit1
  find ./ -type f -exec sed -i -e 's/prompt_toolkit/prompt_toolkit1/g' {} \;
  ${MINGW_PREFIX}/bin/python2 setup.py build
}

package() {
  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1 --skip-build
  install -Dm644 LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}1/LICENSE
}
